home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / AIncludes / AppleEvents.a < prev    next >
Encoding:
Text File  |  1992-01-29  |  24.1 KB  |  585 lines  |  [TEXT/MPS ]

  1.  
  2. ; Created: Monday, October 14, 1991 10:32 AM
  3. ;
  4. ; File: AppleEvents.a
  5. ;
  6. ; Assembler Interface to the Macintosh Libraries
  7. ; Copyright Apple Computer, Inc. 1991
  8. ; All Rights Reserved
  9. ;
  10. ;___________________________________________________________________________
  11.  
  12.  IF &TYPE('__IncludingAppleEvents__') = 'UNDEFINED' THEN
  13. __IncludingAppleEvents__   SET 1
  14.  
  15.  IF &TYPE('__IncludingTraps__') = 'UNDEFINED' THEN
  16.  INCLUDE 'Traps.a'
  17.  ENDIF
  18.  
  19.  
  20. typeLongInteger          EQU          'long'
  21. typeShortInteger         EQU          'shor'
  22. typeLongFloat            EQU          'doub'
  23. typeShortFloat           EQU          'sing'
  24. typeExtended             EQU          'exte'
  25. typeComp                 EQU          'comp'
  26. typeMagnitude            EQU          'magn'
  27. typeAEList               EQU          'list'
  28. typeAERecord             EQU          'reco'
  29. typeTrue                 EQU          'true'
  30. typeFalse                EQU          'fals'
  31. typeAlias                EQU          'alis'
  32. typeEnumerated           EQU          'enum'
  33. typeType                 EQU          'type'
  34. typeAppParameters        EQU          'appa'
  35. typeProperty             EQU          'prop'
  36. typeFSS                  EQU          'fss '
  37. typeKeyword              EQU          'keyw'
  38. typeSectionH             EQU          'sect'
  39. typeWildCard             EQU          '****'
  40.  
  41. typeApplSignature        EQU          'sign'
  42. typeSessionID            EQU          'ssid'
  43. typeTargetID             EQU          'targ'
  44. typeProcessSerialNumber  EQU          'psn '
  45. typeNull                 EQU          'null'         ;the type of null/nonexistent data
  46.  
  47. kCoreEventClass          EQU          'aevt'
  48.  
  49. kAEOpenApplication       EQU          'oapp'
  50. kAEOpenDocuments         EQU          'odoc'
  51. kAEPrintDocuments        EQU          'pdoc'
  52. kAEQuitApplication       EQU          'quit'
  53.  
  54. kAECreatorType           EQU          'crea'
  55. kAEQuitAll               EQU          'quia'
  56. kAEShutDown              EQU          'shut'
  57. kAERestart               EQU          'rest'
  58. kAEApplicationDied       EQU          'obit'
  59. keyProcessSerialNumber   EQU          'psn '
  60.  
  61. keyErrorNumber           EQU          'errn'
  62. keyErrorString           EQU          'errs'
  63.  
  64. kAEAnswer                EQU          'ansr'
  65.  
  66. keyDirectObject          EQU          '----'
  67.  
  68.  
  69. ; keyword used in install special handler 
  70. keyPreDispatch           EQU          'phac'         ; PreHandler Accessor Call 
  71. keySelectProc            EQU          'selh'         ; More selector Call 
  72.  
  73. ; keywords used in attributes 
  74. keyTransactionIDAttr     EQU          'tran'
  75. keyReturnIDAttr          EQU          'rtid'
  76. keyEventClassAttr        EQU          'evcl'
  77. keyEventIDAttr           EQU          'evid'
  78. keyAddressAttr           EQU          'addr'
  79. keyOptionalKeywordAttr   EQU          'optk'
  80. keyTimeoutAttr           EQU          'timo'
  81. keyInteractLevelAttr     EQU          'inte'         ;this attribute is read only will be set in AESend
  82. keyEventSourceAttr       EQU          'esrc'         ; this attribute is read only 
  83. keyMissedKeywordAttr     EQU          'miss'         ; this attribute is read only 
  84.  
  85. ; constants for use in AESendMode 
  86. kAENoReply               EQU          $00000001      ; Sender doesn't want a reply to event 
  87. kAEQueueReply            EQU          $00000002      ; Sender wants a reply but won't wait 
  88. kAEWaitReply             EQU          $00000003      ; Sender wants a reply and will be waiting 
  89.  
  90. kAENeverInteract         EQU          $00000010      ; Server should not interact with user 
  91. kAECanInteract           EQU          $00000020      ; Server may try to interact with user 
  92. kAEAlwaysInteract        EQU          $00000030      ; Server should always interact with user where appropriate 
  93.  
  94. kAECanSwitchLayer        EQU          $00000040      ; Interaction may switch layer 
  95.  
  96. kAEDontReconnect         EQU          $00000080      ; don't reconnect if there is a sessClosedErr from PPCToolbox 
  97.  
  98. kAEWantReceipt           EQU          $00000200      ; Send wants a receipt of message 
  99.  
  100. ; constants to be used in AESendPriority 
  101. kAENormalPriority        EQU          $00000000      ; Post message at the end of event queue 
  102. kAEHighPriority          EQU          $00000001      ; Post message at the front of the event queue 
  103.  
  104. ; special constants in generating events 
  105. kAnyTransactionID        EQU          0              ; no transaction is in use 
  106. kAutoGenerateReturnID    EQU          -1             ; AECreateAppleEvent will generate a session-unique ID 
  107.  
  108. ; constant for use AESend 
  109. kAEDefaultTimeout        EQU          -1             ; timeout value determined by AEM 
  110. kNoTimeOut               EQU          -2             ; wait until reply comes back, however long it takes 
  111.  
  112. ; dispatch parameter to AEResumeTheCurrentEvent takes a pointer to a dispatch
  113. ;table, or one of these two constants 
  114. kAENoDispatch            EQU          0
  115. kAEUseStandardDispatch   EQU          -1
  116.  
  117. ; Error messages in response to reading and writing event contents 
  118. errAECoercionFail        EQU          -1700
  119. errAEDescNotFound        EQU          -1701
  120. errAECorruptData         EQU          -1702
  121. errAEWrongDataType       EQU          -1703
  122. errAENotAEDesc           EQU          -1704
  123. errAEBadListItem         EQU          -1705          ; Specified list item does not exist 
  124. errAENewerVersion        EQU          -1706          ; Need newer version of AppleEvent Manager 
  125. errAENotAppleEvent       EQU          -1707          ; The event is not in AppleEvent format 
  126.  
  127. ; Error messages in response to sending/receiving a message 
  128. errAEEventNotHandled     EQU          -1708          ; The AppleEvent was not handled by any handler 
  129. errAEReplyNotValid       EQU          -1709          ; AEResetTimer was passed an invalid reply parameter 
  130. errAEUnknownSendMode     EQU          -1710          ; Mode wasn't NoReply, WaitReply, or QueueReply;     or Interaction level is unknown 
  131. errAEWaitCanceled        EQU          -1711          ; In AESend, User cancelled out of wait loop for  reply or receipt 
  132. errAETimeout             EQU          -1712          ; AppleEvent timed out 
  133.  
  134. errAENoUserInteraction   EQU          -1713          ; no user interaction allowed 
  135. errAENotASpecialFunction EQU          -1714          ; there is no special function with this keyword 
  136. errAEParamMissed         EQU          -1715          ; a required parameter was not accessed 
  137.  
  138. errAEUnknownAddressType  EQU          -1716          ; The target address type is not known 
  139. errAEHandlerNotFound     EQU          -1717          ; No handler in the dispatch tables fits the parameters to
  140.                          ;                                              AEGetEventHandler or AEGetCoercionHandler
  141.  
  142. errAEReplyNotArrived     EQU          -1718          ; the contents of the reply you are accessing have not arrived yet 
  143. errAEIllegalIndex        EQU          -1719          ; Index is out of range in a put operation 
  144.  
  145. ; tagged data, the standard AppleEvent data type 
  146. AEDesc                   RECORD       0
  147. descriptorType           DS.L         1              ; DescType
  148. dataHandle               DS.L         1              ; Handle
  149. size                     EQU          *
  150.                          ENDR
  151.  
  152.  
  153. ;type of param to AEGetInteractionAllowed and AESetInteractionAllowed
  154. kAEInteractWithSelf      EQU          0
  155. kAEInteractWithLocal     EQU          1
  156. kAEInteractWithAll       EQU          2
  157.  
  158. ;Return param to AEGetTheCurrentEvent, and kAEEventSource attribute
  159. kAEUnknownSource         EQU          0
  160. kAEDirectCall            EQU          1
  161. kAESameProcess           EQU          2
  162. kAELocalProcess          EQU          3
  163. kAERemoteProcess         EQU          4
  164.  
  165.  
  166. ; types for AppleEvent Array support 
  167.  
  168. ; Basic data type of attibutes & parameters
  169. AEKeyDesc                RECORD       0
  170. descKey                  DS.L         1              ; AEKeyword
  171. descContent              DS           AEDesc
  172. size                     EQU          *
  173.                          ENDR
  174.  
  175.  
  176. kAEDataArray             EQU          0
  177. kAEPackedArray           EQU          1
  178. kAEHandleArray           EQU          2
  179. kAEDescArray             EQU          3
  180. kAEKeyDescArray          EQU          4
  181.  
  182.  
  183. ; Array routines support these different types of elements
  184. AEArrayData              RECORD       0
  185.                          ORG           AEArrayData
  186. AEDataArray              DS.W         1              ; Array of short
  187.                          ORG           AEArrayData
  188. AEPackedArray            DS.B         1              ; Array of char
  189.                          ORG           AEArrayData
  190. AEHandleArray            DS.L         1              ; Array of Handle
  191.                          ORG           AEArrayData
  192. AEDescArray              DS.B         AEDesc.size*1
  193.                          ORG           AEArrayData
  194. AEKeyDescArray           DS.B         AEKeyDesc.size*1
  195.                          ORG
  196. size                     EQU          *
  197.                          ENDR
  198.  
  199.  
  200.  
  201. ;  *********************************************************************
  202. ;The following calls apply to any AEDesc. Every result descriptor is created for you,
  203. ;so you will be responsible for memory management of the descriptors so created.
  204. ;Purgeable descriptor data is not supported: the AEM does not call LoadResource.  
  205.                          MACRO
  206.                          _AECreateDesc
  207.                          MOVE.W           #$0825,D0
  208.                          _Pack8                      ; A816
  209.                          ENDM
  210.  
  211.                          MACRO
  212.                          _AECoercePtr
  213.                          MOVE.W           #$0A02,D0
  214.                          _Pack8                      ; A816
  215.                          ENDM
  216.  
  217.                          MACRO
  218.                          _AECoerceDesc
  219.                          MOVE.W           #$0603,D0
  220.                          _Pack8                      ; A816
  221.                          ENDM
  222.  
  223.                          MACRO
  224.                          _AEDisposeDesc
  225.                          MOVE.W           #$0204,D0
  226.                          _Pack8                      ; A816
  227.                          ENDM
  228.  
  229.                          MACRO
  230.                          _AEDuplicateDesc
  231.                          MOVE.W           #$0405,D0
  232.                          _Pack8                      ; A816
  233.                          ENDM
  234.  
  235. ;*********************************************************************
  236. ; The following calls apply to AEDescList.
  237. ;  Since AEDescList is a subtype of AEDesc, the calls in the previous
  238. ;  section can also be used for AEDescList. All list and array indices are 1-based.
  239. ;  If the data was greater than maximumSize in the routines below, then actualSize will
  240. ;  be greater than maximumSize, but only maximumSize bytes will actually be retrieved.
  241.                          MACRO
  242.                          _AECreateList
  243.                          MOVE.W           #$0706,D0
  244.                          _Pack8                      ; A816
  245.                          ENDM
  246.  
  247.                          MACRO
  248.                          _AECountItems
  249.                          MOVE.W           #$0407,D0
  250.                          _Pack8                      ; A816
  251.                          ENDM
  252.  
  253.                          MACRO
  254.                          _AEPutPtr
  255.                          MOVE.W           #$0A08,D0
  256.                          _Pack8                      ; A816
  257.                          ENDM
  258.  
  259.                          MACRO
  260.                          _AEPutDesc
  261.                          MOVE.W           #$0609,D0
  262.                          _Pack8                      ; A816
  263.                          ENDM
  264.  
  265.                          MACRO
  266.                          _AEGetNthPtr
  267.                          MOVE.W           #$100A,D0
  268.                          _Pack8                      ; A816
  269.                          ENDM
  270.  
  271.                          MACRO
  272.                          _AEGetNthDesc
  273.                          MOVE.W           #$0A0B,D0
  274.                          _Pack8                      ; A816
  275.                          ENDM
  276.  
  277.                          MACRO
  278.                          _AESizeOfNthItem
  279.                          MOVE.W           #$082A,D0
  280.                          _Pack8                      ; A816
  281.                          ENDM
  282.  
  283.                          MACRO
  284.                          _AEGetArray
  285.                          MOVE.W           #$0D0C,D0
  286.                          _Pack8                      ; A816
  287.                          ENDM
  288.  
  289.                          MACRO
  290.                          _AEPutArray
  291.                          MOVE.W           #$0B0D,D0
  292.                          _Pack8                      ; A816
  293.                          ENDM
  294.  
  295.                          MACRO
  296.                          _AEDeleteItem
  297.                          MOVE.W           #$040E,D0
  298.                          _Pack8                      ; A816
  299.                          ENDM
  300.  
  301. ;*********************************************************************
  302. ;The following calls apply to AERecord.
  303. ;  Since AERecord is a subtype of AEDescList, the calls in the previous
  304. ;  sections can also be used for AERecord
  305. ;  an AERecord can be created by using AECreateList with isRecord set to true 
  306.                          MACRO
  307.                          _AEPutKeyPtr
  308.                          MOVE.W           #$0A0F,D0
  309.                          _Pack8                      ; A816
  310.                          ENDM
  311.  
  312.                          MACRO
  313.                          _AEPutKeyDesc
  314.                          MOVE.W           #$0610,D0
  315.                          _Pack8                      ; A816
  316.                          ENDM
  317.  
  318.                          MACRO
  319.                          _AEGetKeyPtr
  320.                          MOVE.W           #$0E11,D0
  321.                          _Pack8                      ; A816
  322.                          ENDM
  323.  
  324.                          MACRO
  325.                          _AEGetKeyDesc
  326.                          MOVE.W           #$0812,D0
  327.                          _Pack8                      ; A816
  328.                          ENDM
  329.  
  330.                          MACRO
  331.                          _AESizeOfKeyDesc
  332.                          MOVE.W           #$0829,D0
  333.                          _Pack8                      ; A816
  334.                          ENDM
  335.  
  336.                          MACRO
  337.                          _AEDeleteKeyDesc
  338.                          MOVE.W           #$0413,D0
  339.                          _Pack8                      ; A816
  340.                          ENDM
  341.  
  342.  
  343. ;    *********************************************************************
  344. ;    The following calls are used to pack and unpack parameters from records of
  345. ;    type AppleEvent. Since AppleEvent is a subtype of AERecord, the calls in the previous
  346. ;    sections can also be used for variables of type AppleEvent. The next six calls
  347. ;    are in fact identical to the six calls for AERecord.
  348.                          MACRO
  349.                          _AEPutParamPtr
  350.                          MOVE.W           #$0A0F,D0
  351.                          _Pack8                      ; A816
  352.                          ENDM
  353.  
  354.                          MACRO
  355.                          _AEPutParamDesc
  356.                          MOVE.W           #$0610,D0
  357.                          _Pack8                      ; A816
  358.                          ENDM
  359.  
  360.                          MACRO
  361.                          _AEGetParamPtr
  362.                          MOVE.W           #$0E11,D0
  363.                          _Pack8                      ; A816
  364.                          ENDM
  365.  
  366.                          MACRO
  367.                          _AEGetParamDesc
  368.                          MOVE.W           #$0812,D0
  369.                          _Pack8                      ; A816
  370.                          ENDM
  371.  
  372.                          MACRO
  373.                          _AESizeOfParam
  374.                          MOVE.W           #$0829,D0
  375.                          _Pack8                      ; A816
  376.                          ENDM
  377.  
  378.                          MACRO
  379.                          _AEDeleteParam
  380.                          MOVE.W           #$0413,D0
  381.                          _Pack8                      ; A816
  382.                          ENDM
  383.  
  384. ;*********************************************************************
  385. ;The following calls also apply to type AppleEvent.  Message attributes are far more restricted, and
  386. ;can only be accessed through the following 5 calls. The various list and record routines cannot be used
  387. ;to access the attributes of an event. 
  388.                          MACRO
  389.                          _AEGetAttributePtr
  390.                          MOVE.W           #$0E15,D0
  391.                          _Pack8                      ; A816
  392.                          ENDM
  393.  
  394.                          MACRO
  395.                          _AEGetAttributeDesc
  396.                          MOVE.W           #$0826,D0
  397.                          _Pack8                      ; A816
  398.                          ENDM
  399.  
  400.                          MACRO
  401.                          _AESizeOfAttribute
  402.                          MOVE.W           #$0828,D0
  403.                          _Pack8                      ; A816
  404.                          ENDM
  405.  
  406.                          MACRO
  407.                          _AEPutAttributePtr
  408.                          MOVE.W           #$0A16,D0
  409.                          _Pack8                      ; A816
  410.                          ENDM
  411.  
  412.                          MACRO
  413.                          _AEPutAttributeDesc
  414.                          MOVE.W           #$0627,D0
  415.                          _Pack8                      ; A816
  416.                          ENDM
  417.  
  418. ;*********************************************************************
  419. ; The next four calls are basic routines used to create, send, and process AppleEvents. 
  420.                          MACRO
  421.                          _AECreateAppleEvent
  422.                          MOVE.W           #$0B14,D0
  423.                          _Pack8                      ; A816
  424.                          ENDM
  425.  
  426.                          MACRO
  427.                          _AESend
  428.                          MOVE.W           #$0D17,D0
  429.                          _Pack8                      ; A816
  430.                          ENDM
  431.  
  432.                          MACRO
  433.                          _AEProcessAppleEvent
  434.                          MOVE.W           #$021B,D0
  435.                          _Pack8                      ; A816
  436.                          ENDM
  437.  
  438. ;During event processing, an event handler may realize that it is likely
  439. ;to exceed the client's timeout limit. Passing the reply to this
  440. ;routine causes a wait event to be generated to ask the client for more time. 
  441.                          MACRO
  442.                          _AEResetTimer
  443.                          MOVE.W           #$0219,D0
  444.                          _Pack8                      ; A816
  445.                          ENDM
  446.  
  447. ;  *********************************************************************
  448. ;The following four calls are available for applications which need more sophisticated control
  449. ;over when and how events are processed. Applications which implement multi-session servers or 
  450. ;which implement their own internal event queueing will probably be the major clients of these
  451. ;routines.  
  452.  
  453. ; Can be called from within a handler to prevent the AEM from disposing of
  454. ;the AppleEvent when the handler returns. Can be used to asynchronously process the 
  455. ;event (as in MacApp).
  456.                          MACRO
  457.                          _AESuspendTheCurrentEvent
  458.                          MOVE.W           #$022B,D0
  459.                          _Pack8                      ; A816
  460.                          ENDM
  461.  
  462.  
  463. ;     Tells the AppleEvent manager that processing is either about to resume or has
  464. ;    been completed on a previously suspended event. The procPtr passed in as the
  465. ;    dispatcher parameter will be called to attempt to redispatch the event. Several
  466. ;    constants for the dispatcher parameter allow special behavior. They are:
  467. ;    - kAEUseStandardDispatch means redispatch as if the event was just received, using the
  468. ;        standard AppleEvent Dispatcher.
  469. ;    - kAENoDispatch means ignore the parameter.
  470. ;        Use this in the case where no redispatch is needed, and the event has been handled.
  471. ;    - non nil means call the routine which dispatcher points to.
  472.                          MACRO
  473.                          _AEResumeTheCurrentEvent
  474.                          MOVE.W           #$0818,D0
  475.                          _Pack8                      ; A816
  476.                          ENDM
  477.  
  478. ;Allows application to examine the currently executing event
  479.                          MACRO
  480.                          _AEGetTheCurrentEvent
  481.                          MOVE.W           #$021A,D0
  482.                          _Pack8                      ; A816
  483.                          ENDM
  484.  
  485. ;Set the current event to the parameter
  486.                          MACRO
  487.                          _AESetTheCurrentEvent
  488.                          MOVE.W           #$022C,D0
  489.                          _Pack8                      ; A816
  490.                          ENDM
  491.  
  492.  
  493. ;    *********************************************************************
  494. ;     The following three calls are used to allow applications to behave courteously 
  495. ;    when a user interaction such as a dialog box is needed. 
  496.                          MACRO
  497.                          _AEGetInteractionAllowed
  498.                          MOVE.W           #$021D,D0
  499.                          _Pack8                      ; A816
  500.                          ENDM
  501.  
  502.                          MACRO
  503.                          _AESetInteractionAllowed
  504.                          MOVE.W           #$011E,D0
  505.                          _Pack8                      ; A816
  506.                          ENDM
  507.  
  508.                          MACRO
  509.                          _AEInteractWithUser
  510.                          MOVE.W           #$061C,D0
  511.                          _Pack8                      ; A816
  512.                          ENDM
  513.  
  514. ; *********************************************************************
  515. ; These calls are used to set up and modify the event dispatch table  }
  516. ;{ Add an AppleEvent Handler 
  517.                          MACRO
  518.                          _AEInstallEventHandler
  519.                          MOVE.W           #$091F,D0
  520.                          _Pack8                      ; A816
  521.                          ENDM
  522.  
  523. ; Remove an AppleEvent Handler 
  524.                          MACRO
  525.                          _AERemoveEventHandler
  526.                          MOVE.W           #$0720,D0
  527.                          _Pack8                      ; A816
  528.                          ENDM
  529.  
  530. ; Get the corresponding AppleEvent Handler 
  531.                          MACRO
  532.                          _AEGetEventHandler
  533.                          MOVE.W           #$0921,D0
  534.                          _Pack8                      ; A816
  535.                          ENDM
  536.  
  537. ; *********************************************************************
  538. ; These calls are used to set up and modify the coercion dispatch table  
  539.                          MACRO
  540.                          _AEInstallCoercionHandler
  541.                          MOVE.W           #$0A22,D0
  542.                          _Pack8                      ; A816
  543.                          ENDM
  544.  
  545. ; Remove a Coercion Handler 
  546.                          MACRO
  547.                          _AERemoveCoercionHandler
  548.                          MOVE.W           #$0723,D0
  549.                          _Pack8                      ; A816
  550.                          ENDM
  551.  
  552. ; Get the corresponding Coercion Handler 
  553.                          MACRO
  554.                          _AEGetCoercionHandler
  555.                          MOVE.W           #$0B24,D0
  556.                          _Pack8                      ; A816
  557.                          ENDM
  558.  
  559.  
  560. ;      *********************************************************************
  561. ;    These calls are used to set up and modify special hooks into the AppleEvent Manager.
  562.  
  563. ;    Install the special handler named by the Keyword  
  564.                          MACRO
  565.                          _AEInstallSpecialHandler
  566.                          MOVE.W           #$0500,D0
  567.                          _Pack8                      ; A816
  568.                          ENDM
  569.  
  570. ; Remove the special handler named by the Keyword 
  571.                          MACRO
  572.                          _AERemoveSpecialHandler
  573.                          MOVE.W           #$0501,D0
  574.                          _Pack8                      ; A816
  575.                          ENDM
  576.  
  577. ; Get the special handler named by the Keyword 
  578.                          MACRO
  579.                          _AEGetSpecialHandler
  580.                          MOVE.W           #$052D,D0
  581.                          _Pack8                      ; A816
  582.                          ENDM
  583.  
  584.                          ENDIF    ;       ...already included